package com.mdb.open.trade.service.trade;


/*
* Copyright (C), 2017-2019 澳发科技(MDB)
* FileName: TfRepaymentOrderService.java
* Author:   you.yichao
* Date:     2019-09-04
* History:
* <author>          <time>          <version>          <desc>
* you.yichao         2019-09-04          V1.00             代码生成器初始生成代码
* -----------------------------------------------------------
* 作者姓名           修改时间           版本号            描述
*/


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mdb.bc.database.mybatisplus.PageUtil;
import com.mdb.bc.database.mybatisplus.SuperService;
import com.mdb.bc.utils.ObjectUtil;
import com.mdb.open.trade.common.MdbDataSource;
import com.mdb.open.trade.domain.bo.trade.QueryRepaymentOrderPageListBo;
import com.mdb.open.trade.domain.po.trade.RepaymentOrder;
import com.mdb.open.trade.mapper.trade.TfRepaymentOrderMapper;
import org.springframework.stereotype.Service;


/**
 * 类描述：
 *  融资还款单表 服务类
 *
 * @author you.yichao
 * @date 2019-09-04
 */
@Service
@DS(MdbDataSource.TRADE)
public class TfRepaymentOrderService extends SuperService<TfRepaymentOrderMapper, RepaymentOrder> {

    /**
     * 分页查询
     * @param bo
     * @return
     */
    public IPage<RepaymentOrder> pageQuery(QueryRepaymentOrderPageListBo bo) {

        LambdaQueryWrapper<RepaymentOrder> queryWrapper = new LambdaQueryWrapper<>();
        if (ObjectUtil.isNotEmpty(bo.getApplyOrderNo())) {
            queryWrapper.eq(RepaymentOrder::getApplyOrderNo, bo.getApplyOrderNo());
        }
        if (ObjectUtil.isNotEmpty(bo.getMerchantName())) {
            queryWrapper.like(RepaymentOrder::getMerchantName, bo.getMerchantName());
        }
        if (ObjectUtil.isNotEmpty(bo.getMerchantNo())) {
            queryWrapper.eq(RepaymentOrder::getMerchantNo, bo.getMerchantNo());
        }
        if (ObjectUtil.isNotEmpty(bo.getBusinessNo())) {
            queryWrapper.eq(RepaymentOrder::getBusinessNo, bo.getBusinessNo());
        }
        if (ObjectUtil.isNotEmpty(bo.getCustomerCode())) {
            queryWrapper.eq(RepaymentOrder::getCustomerCode, bo.getCustomerCode());
        }
        if (ObjectUtil.isNotEmpty(bo.getStartDate()) && ObjectUtil.isNotEmpty(bo.getEndDate())) {
            queryWrapper.between(RepaymentOrder::getExpiryDate, bo.getStartDate(), bo.getEndDate());
        }
        if (ObjectUtil.isNotEmpty(bo.getRepaymentStatus())) {
            queryWrapper.eq(RepaymentOrder::getRepaymentStatus, bo.getRepaymentStatus());
        }
        if (ObjectUtil.isNotEmpty(bo.getOverdueStatus())) {
            queryWrapper.eq(RepaymentOrder::getOverdueStatus, bo.getOverdueStatus());
        }

        return this.baseMapper.selectPage(PageUtil.initPage(bo), queryWrapper);
    }

}
